#include<stdio.h>

int a[25][25];

int main()
{
	int n;	scanf("%d", &n);
	int cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			printf("%4d", cnt % 10);
			cnt++;
		}
		printf("\n");
	}
	return 0;
}